#!/usr/bin/env python3
#一款简单的子域名爆破工具,只能说[+]代表有这个玩意，至于通不通在另说吧。
import requests
file_name = "./percolationTest/subDomanDict.txt"
doman = input("请输入要爆破的域名如 'baidu.com'")

def bomb_sub_doman(sub_doman_name,doman_name):
    target_url = "https://{}.{}".format(sub_doman_name,doman_name)
    headers = {
        'User-Agent': 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/7.0)'
    }
    try:
        requests.head = headers#设置请求头，防反爬。
        requests.get(target_url)
        print('[+]'+target_url)
    except requests.ConnectionError:
        print('[-]'+target_url)

if doman:
    with open(file_name,"r",encoding = "utf_8")as file:
        files = file.read().splitlines()#splitlines()按照换行符分割成字符串列表
        print('该字典一共有{}个子域名'.format(len(files)))
        for i in files:
            bomb_sub_doman(i,doman)
else:
    print("域名输入不能为空")
